package regexInput;

import java.io.Serializable;


public class Node implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3976196361015593641L;
	private String name;
	private String subCharClass;
	private char[] specList;
	private String theRegExp;

	public Node(String word, int theScope){
		setName(word);
	}
	
	public Node(){
		setName("");
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSubCharClass() {
		return subCharClass;
	}

	public void setSubCharClass(String subCharClass) {
		this.subCharClass = subCharClass;
	}

	public char[] getList() {
		return specList;
	}
	
	public String getStringList(){
		if(specList == null){
			return "";
		}
		int index = 0;
		String str = "[";
		while(index < specList.length - 1){
			str += specList[index] + ",";
			index++;
		}
		str += specList[index] + "]";
		return str;
	}

	public void addTheSpecs(char[] charList) {
		if(specList == null){
			specList = charList;
		}
		else{
			//We might have character class that contains two different ranges
			//Make a new list
		}
	}

	public String getTheRegExp() {
		return theRegExp;
	}

	public void setTheRegExp(String theRegExp) {
		this.theRegExp = theRegExp;
	}

	public void addPairs(Node thePair) {
	
	}
	
	public String toString(int form){
		String str = "";
		if(form == 1){
			str += "NAME: " + getName() + "\n";
			str += "SPEC: " + getStringList() + "\n";
			str += "SUB:  " + getSubCharClass() + "\n\n";
		}
		else if(form == 2){
			str += "NAME: " + getName() + "\n";
			str += "REG EXPRESSION: " + getTheRegExp() + "\n\n";
		}
		return str;
	}
}
